<?php

namespace common\models\gradeship;

use Yii;
use yii\behaviors\TimestampBehavior;
/**
 * This is the model class for table "gradeship".
 *
 * @property integer $id
 * @property string $category
 * @property string $name
 * @property integer $created_at
 * @property integer $updated_at
 * @property integer $status
 * @property string $value
 * @property string $context
 * @property integer $gradeid
 */
class Gradeship extends \yii\db\ActiveRecord
{
    private $_statusLabel;
    const STATUS_DELETED = 0;
    const STATUS_ACTIVE = 10;

    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
            ],
        ];
    }

    /**
     * @inheritdoc
     */
    public function getStatusLabel()
    {
        if ($this->_statusLabel === null) {
            $statuses = self::getArrayStatus();
            $this->_statusLabel = array_key_exists($this->status,self::getArrayStatus()) ? $statuses[$this->status] : '无';
        }
        return $this->_statusLabel;
    }
    /**
     * @inheritdoc
     */
    public static function getArrayStatus()
    {
        return [
            self::STATUS_ACTIVE => Yii::t('app', 'STATUS_ACTIVE'),
            self::STATUS_DELETED => Yii::t('app', 'STATUS_INACTIVE'),

        ];
    }

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'gradeship';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['created_at', 'updated_at', 'status', 'gradeid'], 'integer'],
            [['context'], 'string'],
            [['category', 'name', 'value'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'category' => Yii::t('app', '分类'),
            'name' => Yii::t('app', '名称'),
            'created_at' => Yii::t('app', '创建时间'),
            'updated_at' => Yii::t('app', '更新时间'),
            'status' => Yii::t('app', '状态'),
            'value' => Yii::t('app', '优惠政策'),
            'context' => Yii::t('app', '内容'),
            'gradeid' => Yii::t('app', '等级ID'),
        ];
    }
}
